'use strict';

module.exports = app => {
  const { INTEGER, STRING, DATE } = app.Sequelize;

  const Comments = app.model.define('comments', {
    id: {
      type: INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    userId: INTEGER,
    houseId: INTEGER,
    msg: STRING(500),
    createTime: {
      type: DATE,
    },
  });

  Comments.associate = () => {
    app.model.Comments.belongsTo(app.model.Users, { foreignKey: 'userId' });
  };

  return Comments;
};
